<template>

    <div class="wai">
      <!-- <audio src="../assets/3238276288.mp3" autoplay="autoplay"></audio> -->
        <div class="bank">
   <div class="form">
        <el-form :model="form" status-icon :rules="rules" ref="form" label-width="100px" class="demo-form" >
            <el-form-item label="用户" prop="username">
    <el-input v-model.number="form.username"></el-input>
  </el-form-item>
            <el-form-item label="密码" prop="password" >
    <el-input type="passwordword" v-model="form.password" autocomplete="off"></el-input>
  </el-form-item>
  
 
  <el-form-item>
    <!-- <el-button type="primary" @click="$router.push(`/home/index`)">提交</el-button> -->
    <el-button type="primary" @click="submitForm">提交</el-button>
    <el-button @click="resetForm('form')">重置</el-button>
  </el-form-item>
</el-form></div ></div>
    </div>
</template>

<script>
import httpApi from '@/http';

    export default {
        data() {
      
      return {
        form: {
          password: '',
          
          username: ''
        },
      
          rules: {
        username: [
          { required: true, message: "请填写用户名", trigger: "blur" },
          {
            pattern: /^\w{3,15}$/,
            message: "3~15位字符，可以包含：数字、字母、下划线",
            trigger: "blur",
          },
        ],
        password: [
          { required: true, message: "请填写用户名", trigger: "blur" },
          {
            pattern: /^\w{6,15}$/,
            message: "6~15位字符，可以包含：数字、字母、下划线",
            trigger: "blur",
          },
        ],
      },
       
      };
    },
    methods: {
      submitForm() {
        this.$refs.form.validate(valid => {
          if (valid) {
            let params={
              username:this.form.username,
              password:this.form.password
            }       
       
            httpApi.adminApi.addArtist(params).then(res => {
              console.log(res);
            if(res.data.code==200){
              this.$router.push(`/home/index`)
              this.$store.commit("saveuser", res.data.data.user)
            }

            })
            
          } else {
        
          }
        })
      },
     
    }
    }
</script>

<style lang="scss" scoped>

.form {
  display: block;
  width: 400px;
  position: absolute;
  top: 30%;
  left: 30%;
  text-align: center;
  font-size: 1.5em;
  color: white;
  margin-bottom: 20px;
}
.bank{
    
    height: 100vh;
  // background-imusername: linear-gradient(125deg, #e14040, #b050cd, #4842c9, #34828d);
  background-size: 500%;
  animation: animate 20s infinite;
}
</style>